/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
 * Description: Hmfs-tools mkfs single unit test
 */

#include "gtest/gtest.h"

#include <cstdio>
#include <cstdlib>
#include <errno.h>
#include <fcntl.h>
#include <fstream>
#include <unistd.h>

#include "constant.h"
#include "compare.h"
#include "whole_compare.h"
#include "hmfs_encoding.h"
#include "hmfs_common.h"
#include "hmfs_test_utils.h"
#include "mkfs_command_parser.h"

using namespace testing;
using namespace testing::ext;

namespace OHOS {
namespace Hmfs {
class MkfsHmfsSingleTest : public testing::Test {
public:
    static void SetUpTestCase();
    static void TearDownTestCase();
    void SetUp() override;
    void TearDown() override;
};

void MkfsHmfsSingleTest::SetUpTestCase()
{
    system("mount -o remount,rw /");
    system("ln -s /bin/fsck.f2fs /bin/dump.f2fs");
    (void)MkfsCmdParser::GetInstance();
}

void MkfsHmfsSingleTest::TearDownTestCase()
{
   system("rm -rf /system/bin/dump.f2fs");
}

void MkfsHmfsSingleTest::SetUp()
{
    system("dd if=/dev/zero of=/data/local/f2fsTest bs=1MB count=100");
    system("dd if=/dev/zero of=/data/local/hmfsTest bs=1MB count=100");
    system("sleep 2");
}

void MkfsHmfsSingleTest::TearDown()
{
    system("rm -rf /data/local/f2fsTest* /data/local/hmfsTest*");
}

/*
 * @tc.name: MkfsHmfsTest_001
 * @tc.desc: test for no parameter
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_no_param_001, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);

    auto f2fsCkeckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(F2FS_DEVICE, f2fsCkeckPoint);

    params.clear();
    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));

    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);

    auto hmfsCkeckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(HMFS_DEVICE, hmfsCkeckPoint);

    SuperBlockCode sbRet = CompareSuperBlock(f2fsSuperBlock, hmfsSuperBlock);
    ASSERT_EQ(SUCCESSED_SB, sbRet);
    CheckPointCode cpRet = CompareCheckPoint(f2fsCkeckPoint, hmfsCkeckPoint);
    ASSERT_EQ(SUCCESSED_CP, cpRet);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_a_001
 * @tc.desc: test for parameter a
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_a_001, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-a 1");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsCkeckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(F2FS_DEVICE, f2fsCkeckPoint);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsCkeckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(HMFS_DEVICE, hmfsCkeckPoint);

    ASSERT_EQ(f2fsCkeckPoint->curNodeSegNo[0], hmfsCkeckPoint->curNodeSegNo[0]);
    ASSERT_EQ(f2fsCkeckPoint->curNodeSegNo[1], hmfsCkeckPoint->curNodeSegNo[1]);
    ASSERT_EQ(f2fsCkeckPoint->curNodeSegNo[2], hmfsCkeckPoint->curNodeSegNo[2]);
    ASSERT_EQ(f2fsCkeckPoint->curDataSegNo[0], hmfsCkeckPoint->curDataSegNo[0]);
    ASSERT_EQ(f2fsCkeckPoint->curDataSegNo[1], hmfsCkeckPoint->curDataSegNo[1]);
    ASSERT_EQ(f2fsCkeckPoint->curDataSegNo[2], hmfsCkeckPoint->curDataSegNo[2]);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_a_002
 * @tc.desc: test for parameter a
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_a_002, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-a 0");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsCkeckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(F2FS_DEVICE, f2fsCkeckPoint);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsCkeckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(HMFS_DEVICE, hmfsCkeckPoint);

    ASSERT_EQ(f2fsCkeckPoint->curNodeSegNo[0], hmfsCkeckPoint->curNodeSegNo[0]);
    ASSERT_EQ(f2fsCkeckPoint->curNodeSegNo[1], hmfsCkeckPoint->curNodeSegNo[1]);
    ASSERT_EQ(f2fsCkeckPoint->curNodeSegNo[2], hmfsCkeckPoint->curNodeSegNo[2]);
    ASSERT_EQ(f2fsCkeckPoint->curDataSegNo[0], hmfsCkeckPoint->curDataSegNo[0]);
    ASSERT_EQ(f2fsCkeckPoint->curDataSegNo[1], hmfsCkeckPoint->curDataSegNo[1]);
    ASSERT_EQ(f2fsCkeckPoint->curDataSegNo[2], hmfsCkeckPoint->curDataSegNo[2]);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_c_001
 * @tc.desc: test for parameter c
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_c_001, TestSize.Level1)
{
    system("dd if=/dev/zero of=/data/local/f2fsTest0 bs=1MB count=100");
    sleep(2);
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-c");
    params.emplace_back(F2FS_DEVICE_PATH_LIST[0]);
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    auto f2fsCkeckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(F2FS_DEVICE, f2fsCkeckPoint);

    system("dd if=/dev/zero of=/data/local/hmfsTest0 bs=1MB count=100");
    sleep(2);
    params.clear();
    params.emplace_back("-c");
    params.emplace_back(HMFS_DEVICE_PATH_LIST[0]);
    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    auto hmfsCkeckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(HMFS_DEVICE, hmfsCkeckPoint);

    ASSERT_EQ(f2fsSuperBlock->blockCount, hmfsSuperBlock->blockCount);
    ASSERT_EQ(f2fsSuperBlock->sectionCount, hmfsSuperBlock->sectionCount);
    ASSERT_EQ(f2fsSuperBlock->segmentCount, hmfsSuperBlock->segmentCount);
    ASSERT_EQ(f2fsSuperBlock->segmentCountInMain, hmfsSuperBlock->segmentCountInMain);
    ASSERT_EQ(f2fsCkeckPoint->userBlockCount, hmfsCkeckPoint->userBlockCount);
    ASSERT_EQ(f2fsCkeckPoint->validBlockCount, hmfsCkeckPoint->validBlockCount);
    ASSERT_EQ(f2fsCkeckPoint->reservedSegmentCount, hmfsCkeckPoint->reservedSegmentCount);
    ASSERT_EQ(f2fsCkeckPoint->overprovisionSegmentCount, hmfsCkeckPoint->overprovisionSegmentCount);
    ASSERT_EQ(f2fsCkeckPoint->freeSegmentCount, hmfsCkeckPoint->freeSegmentCount);

    SuperBlockCode sbRet = CompareSuperBlock(f2fsSuperBlock, hmfsSuperBlock);
    ASSERT_EQ(SUCCESSED_SB, sbRet);
    CheckPointCode cpRet = CompareCheckPoint(f2fsCkeckPoint, hmfsCkeckPoint);
    ASSERT_EQ(SUCCESSED_CP, cpRet);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_c_002
 * @tc.desc: test for parameter c
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_c_002, TestSize.Level1)
{
    for (uint8_t i = 1; i < MAX_DEVICE_COUNTS; i++) {
        DataDuplicatorDevice(HMFS_DEVICE_PATH_LIST[i]);
        DataDuplicatorDevice(F2FS_DEVICE_PATH_LIST[i]);
    }

    std::vector<std::string> params;
    for (uint8_t i = 1; i < MAX_DEVICE_COUNTS; i++) {
        params.emplace_back("-c");
        params.emplace_back(F2FS_DEVICE_PATH_LIST[i]);
    }
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    auto f2fsCkeckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(F2FS_DEVICE, f2fsCkeckPoint);

    params.clear();
    for (uint8_t i = 1; i < MAX_DEVICE_COUNTS; i++) {
        params.emplace_back("-c");
        params.emplace_back(HMFS_DEVICE_PATH_LIST[i]);
    }

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    auto hmfsCkeckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(HMFS_DEVICE, hmfsCkeckPoint);

    SuperBlockCode sbRet = CompareSuperBlock(f2fsSuperBlock, hmfsSuperBlock);
    ASSERT_EQ(SUCCESSED_SB, sbRet);
    CheckPointCode cpRet = CompareCheckPoint(f2fsCkeckPoint, hmfsCkeckPoint);
    ASSERT_EQ(SUCCESSED_CP, cpRet);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_c_003
 * @tc.desc: test for parameter c,
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_c_003, TestSize.Level1)
{
    for (uint8_t i = 0; i < MAX_DEVICE_COUNTS; i++) {
        DataDuplicatorDevice(HMFS_DEVICE_PATH_LIST[i]);
        DataDuplicatorDevice(F2FS_DEVICE_PATH_LIST[i]);
    }

    std::vector<std::string> params;
    for (uint8_t i = 0; i < MAX_DEVICE_COUNTS; i++) {
        params.emplace_back("-c");
        params.emplace_back(F2FS_DEVICE_PATH_LIST[i]);
    }
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    ASSERT_NE(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    params.clear();
    for (uint8_t i = 0; i < MAX_DEVICE_COUNTS; i++) {
        params.emplace_back("-c");
        params.emplace_back(HMFS_DEVICE_PATH_LIST[i]);
    }

    ASSERT_NE(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
}

/*
 * @tc.name: MkfsHmfsTest_c_004
 * @tc.desc: test for parameter c
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_c_004, TestSize.Level1)
{
    system("mkdir -p /data/xxxxxxxxx/xxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxxx");
    ExecutableDdCmd("/data/xxxxxxxxx/xxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxxx/hmfsTest1", 100);
    std::vector<std::string> params;
    params.emplace_back("-c /data/xxxxxxxxx/xxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxxx/hmfsTest1");
    uint64_t hmfsRuntime = 0;
    ASSERT_NE(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    system("rm -rf /data/xxxxxxxxx");
}

/*
 * @tc.name: MkfsHmfsTest_e_001
 * @tc.desc: test for parameter e
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_e_001, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    std::string fileSuffix = "cold";
    params.emplace_back("-e");
    params.emplace_back(fileSuffix);
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);

    ASSERT_EQ(f2fsSuperBlock->coldExtensionCount, hmfsSuperBlock->coldExtensionCount);
    bool flag = false;

    for(int32_t i = 0; i < EXTENSION_COUNT_MAX; i++) {
        ASSERT_STREQ(reinterpret_cast<const char*>(f2fsSuperBlock->extensionList[i]),
            reinterpret_cast<const char*>(hmfsSuperBlock->extensionList[i]));
        if (strcmp(reinterpret_cast<const char*>(hmfsSuperBlock->extensionList[i]), fileSuffix.c_str()) == 0) {
            flag = true;
        }
    }
    ASSERT_TRUE(flag);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_e_002
 * @tc.desc: test for parameter e, fileSuffix length is 7
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_e_002, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    std::string fileSuffix = "xxxxxxx";
    params.emplace_back("-e");
    params.emplace_back(fileSuffix);
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);

    ASSERT_EQ(f2fsSuperBlock->coldExtensionCount, hmfsSuperBlock->coldExtensionCount);
    bool flag = false;

    for(int32_t i = 0; i < EXTENSION_COUNT_MAX; i++) {
        ASSERT_STREQ(reinterpret_cast<const char*>(f2fsSuperBlock->extensionList[i]),
            reinterpret_cast<const char*>(hmfsSuperBlock->extensionList[i]));
        if (strcmp(reinterpret_cast<const char*>(hmfsSuperBlock->extensionList[i]), fileSuffix.c_str()) == 0) {
            flag = true;
        }
    }
    ASSERT_TRUE(flag);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_e_003
 * @tc.desc: test for parameter e, fileSuffix length is 8
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_e_003, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    std::string fileSuffix = "xxxxxxxx";
    params.emplace_back("-e");
    params.emplace_back(fileSuffix);
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);

    ASSERT_EQ(f2fsSuperBlock->coldExtensionCount, hmfsSuperBlock->coldExtensionCount);
    bool flag = false;

    for(int32_t i = 0; i < EXTENSION_COUNT_MAX; i++) {
        ASSERT_STREQ(reinterpret_cast<const char*>(f2fsSuperBlock->extensionList[i]),
            reinterpret_cast<const char*>(hmfsSuperBlock->extensionList[i]));
        if (strcmp(reinterpret_cast<const char*>(hmfsSuperBlock->extensionList[i]), fileSuffix.c_str()) == 0) {
            flag = true;
        }
    }
    ASSERT_FALSE(flag);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_E_001
 * @tc.desc: test for parameter E
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_E_001, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    std::string fileSuffix = "hot";
    params.emplace_back("-E");
    params.emplace_back(fileSuffix);
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);

    ASSERT_EQ(f2fsSuperBlock->hotExtensionCount, hmfsSuperBlock->hotExtensionCount);
    ASSERT_EQ(f2fsSuperBlock->coldExtensionCount, hmfsSuperBlock->coldExtensionCount);
    bool flag = false;

    for(int32_t i = 0; i < EXTENSION_COUNT_MAX; i++) {
        ASSERT_STREQ(reinterpret_cast<const char*>(f2fsSuperBlock->extensionList[i]),
            reinterpret_cast<const char*>(hmfsSuperBlock->extensionList[i]));
        if (strcmp(reinterpret_cast<const char*>(hmfsSuperBlock->extensionList[i]), fileSuffix.c_str()) == 0) {
            flag = true;
        }
    }
    ASSERT_TRUE(flag);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_E_002
 * @tc.desc: test for parameter E, fileSuffix length is 7
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_E_002, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    std::string fileSuffix = "hhhhhhh";
    params.emplace_back("-E");
    params.emplace_back(fileSuffix);
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);

    ASSERT_EQ(f2fsSuperBlock->hotExtensionCount, hmfsSuperBlock->hotExtensionCount);
    ASSERT_EQ(f2fsSuperBlock->coldExtensionCount, hmfsSuperBlock->coldExtensionCount);
    bool flag = false;

    for(int32_t i = 0; i < EXTENSION_COUNT_MAX; i++) {
        ASSERT_STREQ(reinterpret_cast<const char*>(f2fsSuperBlock->extensionList[i]),
            reinterpret_cast<const char*>(hmfsSuperBlock->extensionList[i]));
        if (strcmp(reinterpret_cast<const char*>(hmfsSuperBlock->extensionList[i]), fileSuffix.c_str()) == 0) {
            flag = true;
        }
    }
    ASSERT_TRUE(flag);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_E_003
 * @tc.desc: test for parameter E, fileSuffix length is 8
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_E_003, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    std::string fileSuffix = "hhhhhhhh";
    params.emplace_back("-E");
    params.emplace_back(fileSuffix);
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);

    ASSERT_EQ(f2fsSuperBlock->hotExtensionCount, hmfsSuperBlock->hotExtensionCount);
    ASSERT_EQ(f2fsSuperBlock->coldExtensionCount, hmfsSuperBlock->coldExtensionCount);
    bool flag = false;

    for(int32_t i = 0; i < EXTENSION_COUNT_MAX; i++) {
        ASSERT_STREQ(reinterpret_cast<const char*>(f2fsSuperBlock->extensionList[i]),
            reinterpret_cast<const char*>(hmfsSuperBlock->extensionList[i]));
        if (strcmp(reinterpret_cast<const char*>(hmfsSuperBlock->extensionList[i]), fileSuffix.c_str()) == 0) {
            flag = true;
        }
    }
    ASSERT_FALSE(flag);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_i_001
 * @tc.desc: test for parameter i
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_i_001, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-i");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);

    auto f2fsCkeckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(F2FS_DEVICE, f2fsCkeckPoint);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);

    auto hmfsCkeckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(HMFS_DEVICE, hmfsCkeckPoint);

    ASSERT_EQ(f2fsSuperBlock->checkPointPayload, hmfsSuperBlock->checkPointPayload);
    ASSERT_EQ(f2fsSuperBlock->segmentCountInNAT, hmfsSuperBlock->segmentCountInNAT);
    ASSERT_EQ(f2fsCkeckPoint->checkPointFlags, hmfsCkeckPoint->checkPointFlags);
    ASSERT_EQ(f2fsCkeckPoint->checksumOffset, hmfsCkeckPoint->checksumOffset);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_l_001
 * @tc.desc: test for parameter l
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_l_001, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-l MyVolume");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    std::u16string volumeNameUtf16(reinterpret_cast<const char16_t*>(f2fsSuperBlock->volumeName));
    std::string f2fsVolumeName = Utf16ToUtf8(volumeNameUtf16);
    ASSERT_FALSE(f2fsVolumeName.empty());

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    volumeNameUtf16 = reinterpret_cast<const char16_t*>(hmfsSuperBlock->volumeName);
    std::string hmfsVolumeName = Utf16ToUtf8(volumeNameUtf16);
    ASSERT_FALSE(hmfsVolumeName.empty());
    ASSERT_STREQ(f2fsVolumeName.c_str(), hmfsVolumeName.c_str());
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_l_002
 * @tc.desc: test for parameter l,the label length is 511, which is less than the maximum label length of 512.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_l_002, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    std::string labalCmd = "-l " + GenerateRandomString(MAX_VOLUME_LENGTH - 1);
    std::cout << "labalCmd = " << labalCmd << std::endl;
    params.emplace_back(labalCmd);
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    std::u16string volumeNameUtf16(reinterpret_cast<const char16_t*>(f2fsSuperBlock->volumeName));
    std::string f2fsVolumeName = Utf16ToUtf8(volumeNameUtf16);
    ASSERT_FALSE(f2fsVolumeName.empty());

    std::cout << "f2fsVolumeName = " << f2fsVolumeName << std::endl;

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    volumeNameUtf16 = reinterpret_cast<const char16_t*>(hmfsSuperBlock->volumeName);
    std::string hmfsVolumeName = Utf16ToUtf8(volumeNameUtf16);
    ASSERT_FALSE(hmfsVolumeName.empty());
    ASSERT_STREQ(f2fsVolumeName.c_str(), hmfsVolumeName.c_str());
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_l_003
 * @tc.desc: test for parameter l,the label length is 512, which is equal to the maximum label length 512.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_l_003, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    std::string labalCmd = "-l " + GenerateRandomString(MAX_VOLUME_LENGTH);
    std::cout << "labalCmd = " << labalCmd << std::endl;
    params.emplace_back(labalCmd);
    ASSERT_NE(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));
    ASSERT_NE(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
}

/*
 * @tc.name: MkfsHmfsTest_m_001
 * @tc.desc: test for parameter m
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_m_001, TestSize.Level1)
{
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-m");
    ASSERT_NE(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
}

/*
 * @tc.name: MkfsHmfsTest_o_001
 * @tc.desc: test for parameter o, the value is 10
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_o_001, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-o 10");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsCkeckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(F2FS_DEVICE, f2fsCkeckPoint);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsCkeckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(HMFS_DEVICE, hmfsCkeckPoint);

    ASSERT_EQ(f2fsCkeckPoint->overprovisionSegmentCount, hmfsCkeckPoint->overprovisionSegmentCount);
    ASSERT_EQ(f2fsCkeckPoint->reservedSegmentCount, hmfsCkeckPoint->reservedSegmentCount);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_o_002
 * @tc.desc: test for parameter o, the value is 99.99
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_o_002, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-o 99.99");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsCkeckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(F2FS_DEVICE, f2fsCkeckPoint);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsCkeckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(HMFS_DEVICE, hmfsCkeckPoint);

    ASSERT_EQ(f2fsCkeckPoint->overprovisionSegmentCount, hmfsCkeckPoint->overprovisionSegmentCount);
    ASSERT_EQ(f2fsCkeckPoint->reservedSegmentCount, hmfsCkeckPoint->reservedSegmentCount);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_o_003
 * @tc.desc: test for parameter o, the value is 100
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_o_003, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-o 100");
    ASSERT_NE(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));
    ASSERT_NE(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
}

/*
 * @tc.name: MkfsHmfsTest_O_000
 * @tc.desc: test for parameter "-O encrypt"
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_O_000, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.clear();
    params.emplace_back("-O encrypt");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    ASSERT_TRUE(hmfsSuperBlock->features & HMFS_FEATURE_ENCRYPT);
    ASSERT_EQ(f2fsSuperBlock->features, hmfsSuperBlock->features);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_O_001
 * @tc.desc: test for parameter "-O extra_attr"
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_O_001, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.clear();
    params.emplace_back("-O extra_attr");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    ASSERT_TRUE(hmfsSuperBlock->features & HMFS_FEATURE_EXTRA_ATTR);
    ASSERT_EQ(f2fsSuperBlock->features, hmfsSuperBlock->features);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_O_002
 * @tc.desc: test for parameter "-O extra_attr,project_quota"
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_O_002, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-O project_quota");
    ASSERT_NE(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));

    params.clear();
    params.emplace_back("-O extra_attr,project_quota");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(F2FS_DEVICE, f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(HMFS_DEVICE, hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    ASSERT_TRUE(hmfsSuperBlock->features & (HMFS_FEATURE_EXTRA_ATTR | HMFS_FEATURE_PRJQUOTA));
    ASSERT_EQ(f2fsSuperBlock->features, hmfsSuperBlock->features);
    ASSERT_EQ(f2fsNodeData->inode.projectId, hmfsNodeData->inode.projectId);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_O_003
 * @tc.desc: test for parameter "-O extra_attr,inode_checksum"
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_O_003, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-O inode_checksum");
    ASSERT_NE(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));

    params.clear();
    params.emplace_back("-O extra_attr,inode_checksum");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(F2FS_DEVICE, f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(HMFS_DEVICE, hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    ASSERT_TRUE(hmfsSuperBlock->features & (HMFS_FEATURE_EXTRA_ATTR | HMFS_FEATURE_INODE_CHKSUM));
    ASSERT_EQ(f2fsSuperBlock->features, hmfsSuperBlock->features);
    ASSERT_NE(0, hmfsNodeData->inode.inodeChecksum);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_O_004
 * @tc.desc: test for parameter "-O extra_attr,flexible_inline_xattr"
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_O_004, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-O flexible_inline_xattr");
    ASSERT_NE(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));

    params.clear();
    params.emplace_back("-O extra_attr,flexible_inline_xattr");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(F2FS_DEVICE, f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(HMFS_DEVICE, hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    ASSERT_TRUE(hmfsSuperBlock->features & (HMFS_FEATURE_EXTRA_ATTR | HMFS_FEATURE_FLEXIBLE_INLINE_XATTR));
    ASSERT_EQ(f2fsSuperBlock->features, hmfsSuperBlock->features);
    ASSERT_EQ(f2fsNodeData->inode.inlineXattrSize, hmfsNodeData->inode.inlineXattrSize);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_O_005
 * @tc.desc: test for parameter "-O quota"
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_O_005, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-O quota");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    ASSERT_TRUE(hmfsSuperBlock->features & HMFS_FEATURE_QUOTA_INO);
    ASSERT_EQ(f2fsSuperBlock->features, hmfsSuperBlock->features);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_O_006
 * @tc.desc: test for parameter "-O extra_attr,inode_crtime"
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_O_006, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-O inode_crtime");
    ASSERT_NE(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));

    params.clear();
    params.emplace_back("-O extra_attr,inode_crtime");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(F2FS_DEVICE, f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(HMFS_DEVICE, hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    ASSERT_TRUE(hmfsSuperBlock->features & (HMFS_FEATURE_EXTRA_ATTR | HMFS_FEATURE_INODE_CRTIME));
    ASSERT_EQ(f2fsSuperBlock->features, hmfsSuperBlock->features);
    ASSERT_NE(hmfsNodeData->inode.creationTime, 0);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_O_007
 * @tc.desc: test for parameter "-O lost_found"
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_O_007, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-O lost_found");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    ASSERT_TRUE(hmfsSuperBlock->features & HMFS_FEATURE_LOST_FOUND);
    ASSERT_EQ(f2fsSuperBlock->features, hmfsSuperBlock->features);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_O_008
 * @tc.desc: test for parameter "-O verity"
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_O_008, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-O verity");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    ASSERT_TRUE(hmfsSuperBlock->features & HMFS_FEATURE_VERITY);
    ASSERT_EQ(f2fsSuperBlock->features, hmfsSuperBlock->features);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_O_009
 * @tc.desc: test for parameter "-O sb_checksum"
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_O_009, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-O sb_checksum");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    ASSERT_TRUE(hmfsSuperBlock->features & HMFS_FEATURE_SB_CHKSUM);
    ASSERT_EQ(f2fsSuperBlock->features, hmfsSuperBlock->features);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_O_010
 * @tc.desc: test for parameter "-O casefold"
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_O_010, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-O casefold");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    ASSERT_TRUE(hmfsSuperBlock->features & HMFS_FEATURE_CASEFOLD);
    ASSERT_EQ(f2fsSuperBlock->features, hmfsSuperBlock->features);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_O_011
 * @tc.desc: test for parameter "-O extra_attr,compression"
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_O_011, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-O compression");
    ASSERT_NE(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));

    params.clear();
    params.emplace_back("-O extra_attr,compression");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(F2FS_DEVICE, f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(HMFS_DEVICE, hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    ASSERT_TRUE(hmfsSuperBlock->features & (HMFS_FEATURE_EXTRA_ATTR | HMFS_FEATURE_COMPRESSION));
    ASSERT_EQ(f2fsSuperBlock->features, hmfsSuperBlock->features);
    ASSERT_EQ(f2fsNodeData->inode.compressedBlockCount, hmfsNodeData->inode.compressedBlockCount);
    ASSERT_EQ(f2fsNodeData->inode.compressionAlgorithm, hmfsNodeData->inode.compressionAlgorithm);
    ASSERT_EQ(f2fsNodeData->inode.logClusterSize, hmfsNodeData->inode.logClusterSize);
    ASSERT_EQ(f2fsNodeData->inode.padding, hmfsNodeData->inode.padding);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_O_012
 * @tc.desc: test for parameter "-O ro"
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_O_012, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-O ro");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    ASSERT_TRUE(hmfsSuperBlock->features & HMFS_FEATURE_RO);
    ASSERT_EQ(f2fsSuperBlock->features, hmfsSuperBlock->features);

    auto hmfsCkeckPoint = std::make_unique<CheckPointData>();
    GetCheckPoint(HMFS_DEVICE, hmfsCkeckPoint);

    ASSERT_EQ(hmfsCkeckPoint->curNodeSegNo[1], 0);
    ASSERT_EQ(hmfsCkeckPoint->curNodeSegNo[2], 0);
    ASSERT_EQ(hmfsCkeckPoint->curDataSegNo[0], 0);
    ASSERT_EQ(hmfsCkeckPoint->curDataSegNo[1], 0);
    ASSERT_EQ(hmfsCkeckPoint->curDataSegNo[2], 0);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_C_001
 * @tc.desc: test for parameter C
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_C_001, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-C");
    params.emplace_back("utf8");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    ASSERT_EQ(f2fsSuperBlock->encoding, hmfsSuperBlock->encoding);
    ASSERT_EQ(f2fsSuperBlock->encodingFlags, hmfsSuperBlock->encodingFlags);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_C_002
 * @tc.desc: test for parameter C
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_C_002, TestSize.Level1)
{
    std::vector<std::string> params;
    params.clear();
    params.emplace_back("-C gbk");
    uint64_t hmfsRuntime = 0;
    ASSERT_NE(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
}

/*
 * @tc.name: MkfsHmfsTest_r_001
 * @tc.desc: test for parameter r
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_r_001, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-r");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_R_001
 * @tc.desc: test for parameter R
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_R_001, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-R 0:0");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(F2FS_DEVICE, f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(HMFS_DEVICE, hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    ASSERT_EQ(f2fsNodeData->inode.userId, hmfsNodeData->inode.userId);
    ASSERT_EQ(f2fsNodeData->inode.groupId, hmfsNodeData->inode.groupId);
    ASSERT_EQ(hmfsNodeData->inode.groupId, 0);
    ASSERT_EQ(hmfsNodeData->inode.groupId, 0);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_R_002
 * @tc.desc: test for parameter R
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_R_002, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-R 1000:1000");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(F2FS_DEVICE, f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(HMFS_DEVICE, hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    ASSERT_EQ(f2fsNodeData->inode.userId, hmfsNodeData->inode.userId);
    ASSERT_EQ(f2fsNodeData->inode.groupId, hmfsNodeData->inode.groupId);
    ASSERT_EQ(hmfsNodeData->inode.groupId, 1000);
    ASSERT_EQ(hmfsNodeData->inode.groupId, 1000);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}
/*
 * @tc.name: MkfsHmfsTest_R_003
 * @tc.desc: test for parameter R
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_R_003, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-R -1000:-1000");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(F2FS_DEVICE, f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(HMFS_DEVICE, hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    ASSERT_EQ(f2fsNodeData->inode.userId, hmfsNodeData->inode.userId);
    ASSERT_EQ(f2fsNodeData->inode.groupId, hmfsNodeData->inode.groupId);
    uint32_t res = -1000;
    ASSERT_EQ(hmfsNodeData->inode.groupId, res);
    ASSERT_EQ(hmfsNodeData->inode.groupId, res);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_s_001
 * @tc.desc: test for parameter s
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_s_001, TestSize.Level1)
{
    std::vector<std::string> params;
    params.clear();
    params.emplace_back("-s 0");
    uint64_t hmfsRuntime = 0;
    ASSERT_NE(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
}

/*
 * @tc.name: MkfsHmfsTest_s_002
 * @tc.desc: test for parameter s
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_s_002, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-s 2");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);

    ASSERT_EQ(f2fsSuperBlock->segsPerSection, hmfsSuperBlock->segsPerSection);
    ASSERT_EQ(f2fsSuperBlock->segmentCountInMain, hmfsSuperBlock->segmentCountInMain);
    ASSERT_EQ(f2fsSuperBlock->sectionCount, hmfsSuperBlock->sectionCount);
    ASSERT_TRUE(hmfsSuperBlock->segsPerSection == 2);
    ASSERT_TRUE(hmfsSuperBlock->sectionCount > 10);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_s_003
 * @tc.desc: test for parameter s
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_s_003, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-s 3");
    ASSERT_NE(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    ASSERT_NE(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
}

/*
 * @tc.name: MkfsHmfsTest_s_004
 * @tc.desc: test for parameter s
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_s_004, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.clear();
    params.emplace_back("-s 1");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));
    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    ASSERT_TRUE(f2fsSuperBlock->segsPerSection == 1);
    ASSERT_TRUE(f2fsSuperBlock->sectionCount > 10);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    ASSERT_TRUE(hmfsSuperBlock->segsPerSection == 1);
    ASSERT_TRUE(hmfsSuperBlock->sectionCount > 10);

    ASSERT_EQ(f2fsSuperBlock->segsPerSection, hmfsSuperBlock->segsPerSection);
    ASSERT_EQ(f2fsSuperBlock->segmentCountInMain, hmfsSuperBlock->segmentCountInMain);
    ASSERT_EQ(f2fsSuperBlock->sectionCount, hmfsSuperBlock->sectionCount);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_S_001
 * @tc.desc: test for parameter S
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_S_001, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-S");
    ASSERT_NE(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    ASSERT_NE(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
}

/*
 * @tc.name: MkfsHmfsTest_t_001
 * @tc.desc: test for parameter t
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_t_001, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-t 0");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
}

/*
 * @tc.name: MkfsHmfsTest_t_002
 * @tc.desc: test for parameter t
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_t_002, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-t 1");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_T_001
 * @tc.desc: test for parameter T
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_T_001, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-T -1000");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(F2FS_DEVICE, f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(HMFS_DEVICE, hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    ASSERT_EQ(f2fsNodeData->inode.accessTime, hmfsNodeData->inode.accessTime);
    ASSERT_EQ(f2fsNodeData->inode.accessTimeNsec, hmfsNodeData->inode.accessTimeNsec);
    ASSERT_EQ(f2fsNodeData->inode.changeTime, hmfsNodeData->inode.changeTime);
    ASSERT_EQ(f2fsNodeData->inode.changeTimeNsec, hmfsNodeData->inode.changeTimeNsec);
    ASSERT_EQ(f2fsNodeData->inode.modificationTime, hmfsNodeData->inode.modificationTime);
    ASSERT_EQ(f2fsNodeData->inode.modificationTimeNsec, hmfsNodeData->inode.modificationTimeNsec);
    uint32_t res = -1000;
    ASSERT_EQ(hmfsNodeData->inode.accessTime, res);
    ASSERT_EQ(hmfsNodeData->inode.changeTime, res);
    ASSERT_EQ(hmfsNodeData->inode.modificationTime, res);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_T_002
 * @tc.desc: test for parameter T
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_T_002, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-T 1731565670");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    auto f2fsNodeData = std::make_unique<NodeData>();
    int16_t f2fsAddrIndex = -1;
    GetInodeInfo(F2FS_DEVICE, f2fsNodeData, f2fsAddrIndex, GetLeValue(f2fsSuperBlock->rootInodeId));

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    auto hmfsNodeData = std::make_unique<NodeData>();
    int16_t hmfsAddrIndex = -1;
    GetInodeInfo(HMFS_DEVICE, hmfsNodeData, hmfsAddrIndex, GetLeValue(hmfsSuperBlock->rootInodeId));

    ASSERT_EQ(f2fsNodeData->inode.accessTime, hmfsNodeData->inode.accessTime);
    ASSERT_EQ(f2fsNodeData->inode.accessTimeNsec, hmfsNodeData->inode.accessTimeNsec);
    ASSERT_EQ(f2fsNodeData->inode.changeTime, hmfsNodeData->inode.changeTime);
    ASSERT_EQ(f2fsNodeData->inode.changeTimeNsec, hmfsNodeData->inode.changeTimeNsec);
    ASSERT_EQ(f2fsNodeData->inode.modificationTime, hmfsNodeData->inode.modificationTime);
    ASSERT_EQ(f2fsNodeData->inode.modificationTimeNsec, hmfsNodeData->inode.modificationTimeNsec);
    ASSERT_EQ(hmfsNodeData->inode.accessTime, 1731565670);
    ASSERT_EQ(hmfsNodeData->inode.changeTime, 1731565670);
    ASSERT_EQ(hmfsNodeData->inode.modificationTime, 1731565670);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_w_001
 * @tc.desc: test for parameter w
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_w_001, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<char*> params;
    params.emplace_back(const_cast<char*>("/system/bin/mkfs.f2fs"));
    params.emplace_back(const_cast<char*>("-w 1024"));
    params.emplace_back(const_cast<char*>("/data/local/f2fsTest"));
    params.emplace_back(const_cast<char*>("15000000"));
    params.emplace_back(nullptr);
    ASSERT_EQ(0, ExecutableCmd(params[0], params.data(), f2fsRuntime));

    params.clear();
    params.emplace_back(const_cast<char*>("/system/bin/mkfs.hmfs"));
    params.emplace_back(const_cast<char*>("-w 1024"));
    params.emplace_back(const_cast<char*>("/data/local/hmfsTest"));
    params.emplace_back(const_cast<char*>("15000000"));
    params.emplace_back(nullptr);
    ASSERT_EQ(0, ExecutableCmd(params[0], params.data(), hmfsRuntime));

    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_w_002
 * @tc.desc: test for parameter w
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_w_002, TestSize.Level1)
{
    //f2fs
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<char*> params;
    params.emplace_back(const_cast<char*>("/system/bin/mkfs.f2fs"));
    params.emplace_back(const_cast<char*>("-w 1024"));
    params.emplace_back(const_cast<char*>("/data/local/f2fsTest"));
    params.emplace_back(const_cast<char*>("49152")); // 12 * 4096
    params.emplace_back(nullptr);
    ASSERT_NE(0, ExecutableCmd(params[0], params.data(), f2fsRuntime));

    params.clear();
    params.emplace_back(const_cast<char*>("/system/bin/mkfs.f2fs"));
    params.emplace_back(const_cast<char*>("-w 1024"));
    params.emplace_back(const_cast<char*>("/data/local/f2fsTest"));
    params.emplace_back(const_cast<char*>("53248")); // 13 * 4096
    params.emplace_back(nullptr);
    ASSERT_EQ(0, ExecutableCmd(params[0], params.data()));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    ASSERT_TRUE(f2fsSuperBlock->sectionCount > 10);

    // hmfs
    params.clear();
    params.emplace_back(const_cast<char*>("/system/bin/mkfs.hmfs"));
    params.emplace_back(const_cast<char*>("-w 1024"));
    params.emplace_back(const_cast<char*>("/data/local/hmfsTest"));
    params.emplace_back(const_cast<char*>("49152")); // 12 * 4096
    params.emplace_back(nullptr);

    ASSERT_NE(0, ExecutableCmd(params[0], params.data(), hmfsRuntime));

    params.clear();
    params.emplace_back(const_cast<char*>("/system/bin/mkfs.hmfs"));
    params.emplace_back(const_cast<char*>("-w 1024"));
    params.emplace_back(const_cast<char*>("/data/local/hmfsTest"));
    params.emplace_back(const_cast<char*>("53248")); // 13 * 4096
    params.emplace_back(nullptr);
    ASSERT_EQ(0, ExecutableCmd(params[0], params.data()));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    ASSERT_TRUE(hmfsSuperBlock->sectionCount > 10);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_w_003
 * @tc.desc: test for parameter w
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_w_003, TestSize.Level1)
{
    //f2fs
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<char*> params;
    params.emplace_back(const_cast<char*>("/system/bin/mkfs.f2fs"));
    params.emplace_back(const_cast<char*>("-w 2048"));
    params.emplace_back(const_cast<char*>("/data/local/f2fsTest"));
    params.emplace_back(const_cast<char*>("24576")); // 6 * 4096
    params.emplace_back(nullptr);
    ASSERT_NE(0, ExecutableCmd(params[0], params.data(), f2fsRuntime));

    params.clear();
    params.emplace_back(const_cast<char*>("/system/bin/mkfs.f2fs"));
    params.emplace_back(const_cast<char*>("-w 2048"));
    params.emplace_back(const_cast<char*>("/data/local/f2fsTest"));
    params.emplace_back(const_cast<char*>("28672")); // 7 * 4096
    params.emplace_back(nullptr);
    ASSERT_EQ(0, ExecutableCmd(params[0], params.data()));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    ASSERT_TRUE(f2fsSuperBlock->sectionCount > 10);

    // hmfs
    params.clear();
    params.emplace_back(const_cast<char*>("/system/bin/mkfs.hmfs"));
    params.emplace_back(const_cast<char*>("-w 2048"));
    params.emplace_back(const_cast<char*>("/data/local/hmfsTest"));
    params.emplace_back(const_cast<char*>("24576")); // 6 * 4096
    params.emplace_back(nullptr);

    ASSERT_NE(0, ExecutableCmd(params[0], params.data(), hmfsRuntime));

    params.clear();
    params.emplace_back(const_cast<char*>("/system/bin/mkfs.hmfs"));
    params.emplace_back(const_cast<char*>("-w 2048"));
    params.emplace_back(const_cast<char*>("/data/local/hmfsTest"));
    params.emplace_back(const_cast<char*>("28672")); // 7 * 4096
    params.emplace_back(nullptr);
    ASSERT_EQ(0, ExecutableCmd(params[0], params.data()));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    ASSERT_TRUE(hmfsSuperBlock->sectionCount > 10);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_z_000
 * @tc.desc: test for parameter z
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_z_000, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-z 0");
    ASSERT_NE(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    ASSERT_NE(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
}

/*
 * @tc.name: MkfsHmfsTest_z_001
 * @tc.desc: test for parameter z
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_z_001, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-z 1");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));
    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    ASSERT_TRUE(f2fsSuperBlock->sectionsPerZone == 1);
    ASSERT_TRUE(f2fsSuperBlock->sectionCount > 10);

    // hmfs
    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    ASSERT_TRUE(hmfsSuperBlock->sectionsPerZone == 1);
    ASSERT_TRUE(hmfsSuperBlock->sectionCount > 10);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_z_002
 * @tc.desc: test for parameter z
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_z_002, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-z 2");
    ASSERT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    auto f2fsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(F2FS_DEVICE, f2fsSuperBlock);
    ASSERT_TRUE(f2fsSuperBlock->sectionsPerZone == 2);
    ASSERT_TRUE(f2fsSuperBlock->sectionCount > 10);

    ASSERT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    ASSERT_TRUE(fsckRes);

    auto hmfsSuperBlock = std::make_unique<SuperBlockData>();
    GetSuperBlock(HMFS_DEVICE, hmfsSuperBlock);
    ASSERT_TRUE(hmfsSuperBlock->sectionsPerZone == 2);
    ASSERT_TRUE(hmfsSuperBlock->sectionCount > 10);

    ASSERT_EQ(f2fsSuperBlock->sectionsPerZone, hmfsSuperBlock->sectionsPerZone);
    ASSERT_EQ(f2fsSuperBlock->sectionCount, hmfsSuperBlock->sectionCount);
    ASSERT_EQ(FsBinaryCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    ASSERT_EQ(FsResultCompare(F2FS_DEVICE, HMFS_DEVICE), 0);
    (void)CompareRunTime(f2fsRuntime, hmfsRuntime);
}

/*
 * @tc.name: MkfsHmfsTest_z_003
 * @tc.desc: test for parameter z
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, Test_param_z_003, TestSize.Level1)
{
    uint64_t f2fsRuntime = 0;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    params.emplace_back("-z 6");
    ASSERT_NE(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));

    ASSERT_NE(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
}

/*
 * @tc.name: MkfsHmfsTest_Abnormal_001
 * @tc.desc: Test for abnormal exit during the execution of the mkfs command.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, MkfsHmfsTest_Abnormal_001, TestSize.Level1)
{
    std::cout << "MkfsHmfsTest_Abnormal_001 BEGIN" << std::endl;
    auto f2fsCheckPoint = std::make_unique<CheckPointData>();
    uint64_t f2fsRuntime = 0;
    std::vector<std::string> params;

    pid_t pid = fork();
    if (pid < 0) {
        assert(pid > 0 && "fork failed with errno = " + std::to_string(errno));
    }
    if (pid == 0) {
        pid_t childId = getpid();
        std::cout << "PID: " << childId << std::endl;
        EXPECT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));
        sleep(10);
    }
    usleep(500);
    kill(pid, SIGKILL);
    std::cout << "Child process terminated" << std::endl;
    int status;
    pid_t resid = waitpid(pid, &status, 0);
    std::cout << "id2Kill: " << resid << std::endl;

    EXPECT_EQ(0, ExecMkfsBinary(F2FS_TYPE, F2FS_DEVICE, params, f2fsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(F2FS_DEVICE);
    EXPECT_TRUE(fsckRes);
    std::cout << "MkfsHmfsTest_Abnormal_001 END" << std::endl;
}

/*
 * @tc.name: MkfsHmfsTest_Abnormal_002
 * @tc.desc: Test for abnormal exit during the execution of the mkfs command.
 * @tc.type: FUNC
 */
HWTEST_F(MkfsHmfsSingleTest, MkfsHmfsTest_Abnormal_002, TestSize.Level1)
{
    std::cout << "MkfsHmfsTest_Abnormal_002 BEGIN" << std::endl;
    uint64_t hmfsRuntime = 0;
    std::vector<std::string> params;
    auto f2fsCheckPoint = std::make_unique<CheckPointData>();
    pid_t pid = fork();
    if (pid < 0) {
        assert(pid > 0 && "fork failed with errno = " + std::to_string(errno));
    }
    if (pid == 0) {
        pid_t childId = getpid();
        std::cout << "PID: " << childId << std::endl;
        EXPECT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
        sleep(10);
    }
    usleep(500);
    kill(pid, SIGKILL);
    std::cout << "Child process terminated" << std::endl;
    int status;
    pid_t resid = waitpid(pid, &status, 0);
    std::cout << "id2Kill: " << resid << std::endl;

    EXPECT_EQ(0, ExecMkfsBinary(HMFS_TYPE, HMFS_DEVICE, params, hmfsRuntime));
    bool fsckRes = ExecFsckBinaryAndCheck(HMFS_DEVICE);
    EXPECT_TRUE(fsckRes);
    std::cout << "MkfsHmfsTest_Abnormal_002 END" << std::endl;
}

} // namespace Hmfs
} // namespace OHOS